package org.jeecg.modules.demo.pointcount.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Transient;

import java.io.Serializable;

/**
 * @Author yw
 * @Date 2021/3/10 10:55
 */
@Data
public class PointCount implements Serializable {
    private static final long serialVersionUID = 1L;


    /**主键*/
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private java.lang.String id;

    private String ctime;

    private String regUserNum;//注册用户总数

    private String pointcount;//打点总数

    private String jlnum;//激励总数

    private String qpnum;//全屏总数

    private String cpnum;//插屏总数

    private String eventNum;//事件代表数值

    private String eventName;//事件名称

    private String dataName;

    private String begintime;

    private String endtime;

    private String system;

    private String type;

    /** zrikka start */
    private String channel;// 渠道
    /** zrikka end */

    //一下为活动参数
    private String num100;
    private String num101;
    private String num102;
    private String num103;
    private String num104;
    private String num105;
    private String num106;
    private String num107;
    private String num108;
    private String num109;
    private String num110;
    private String num111;
    private String num112;
    private String num113;
    private String num114;
    private String num115;
    private String num116;
    private String num201;
    private String num202;
    private String num203;
    private String num204;
    private String num301;
    private String num302;
    private String num303;
    private String num304;
    private String num305;

    //非表字段，为自定义参数
    @Transient
    private String tableName;
    @Transient
    private Integer pageNo;
    @Transient
    private Integer pageSize;

    /** zrikka start */
    /** 数量设置 */
    public void settingNum(Integer num,String val){
        switch(num){
            case 100 :
                num100 = val;
                break;
            case 101 :
                num101 = val;
                break;
            case 102 :
                num102 = val;
                break;
            case 103 :
                num103 = val;
                break;
            case 104 :
                num104 = val;
                break;
            case 105 :
                num105 = val;
                break;
            case 106 :
                num106 = val;
                break;
            case 107 :
                num107 = val;
                break;
            case 108 :
                num108 = val;
                break;
            case 109 :
                num109 = val;
                break;
            case 110 :
                num110 = val;
                break;
            case 111 :
                num111 = val;
                break;
            case 112 :
                num112 = val;
                break;
            case 113 :
                num113 = val;
                break;
            case 114 :
                num114 = val;
                break;
            case 115 :
                num115 = val;
                break;
            case 116 :
                num116 = val;
                break;
            case 201 :
                num201 = val;
                break;
            case 202 :
                num202 = val;
                break;
            case 203 :
                num203 = val;
                break;
            case 204 :
                num204 = val;
                break;
            case 301 :
                num301 = val;
                break;
            case 302 :
                num302 = val;
                break;
            case 303 :
                num303 = val;
                break;
            case 304 :
                num304 = val;
                break;
            case 305 :
                num305 = val;
                break;
        }
    }

    public void settingNum(){
        settingJlnum();
        settingQpnum();
        settingCpnum();
        pointcount =String.valueOf(Integer.valueOf(jlnum) + Integer.valueOf(qpnum) + Integer.valueOf(cpnum));
    }

    // 设置 激励总数
    private void settingJlnum() {
        String[] arr = {num100,num101,num102,num103,num104,num105,num106,num107,num108,num109,num110,num111,num112,num113,num114,num115,num116};
        jlnum = String.valueOf(sumResult(arr));
    }

    // 设置 全屏总数
    private void settingQpnum() {
        String[] arr = {num201,num202,num203,num204};
        qpnum = String.valueOf(sumResult(arr));
    }

    // 设置 插屏总数
    private void settingCpnum() {
        String[] arr = {num301,num302,num303,num304,num305};
        cpnum = String.valueOf(sumResult(arr));
    }

    private int sumResult(String[] numArr){
        int total = 0;
        for(String num : numArr){
            total = countSum(total,num);
        }
        return total;
    }

    private int countSum(int total,String num){
        int nownum = 0;
        if(num != null && !"".equals(num)){
            nownum = Integer.valueOf(num);
        }
        total += nownum;
        return total;
    }
    /** zrikka end */


}
